package com.shanzmoo.h5.domain.vo;

import com.shanzmoo.db.mall.entity.vo.MallOrderDetailVO;
import com.shanzmoo.db.order.entity.dto.MallOrderRedisDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 商城订单简要信息
 *
 * @author Gzhao 2020/12/25
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor(access = AccessLevel.PRIVATE)
@ApiModel("商城订单简要信息")
public class MallOrderBriefVO implements Serializable {

    private static final long serialVersionUID = 1758L;

    @ApiModelProperty(name = "订单ID")
    private Integer id;

    @ApiModelProperty(name = "订单号")
    private String orderNo;

    @ApiModelProperty(name = "订单状态：0-待支付 1-待发货 2-已发货 3-已完成")
    private Integer status;

    @ApiModelProperty(name = "商品总金额")
    private BigDecimal goodsAmount;

    @ApiModelProperty(name = "优惠券金额")
    private BigDecimal couponAmount;

    @ApiModelProperty(name = "运费")
    private BigDecimal freight;

    @ApiModelProperty(name = "实付金额")
    private BigDecimal receiveAmount;

    @ApiModelProperty(name = "商城订单商品明细")
    private List<MallOrderDetailVO> orderDetailList;

    public static MallOrderBriefVO create(MallOrderRedisDTO orderRedisDTO) {
        MallOrderBriefVO orderBriefVO = MallOrderBriefVO.builder()
                .id(orderRedisDTO.getId())
                .orderNo(orderRedisDTO.getOrderNo())
                .status(orderRedisDTO.getStatus())
                .goodsAmount(orderRedisDTO.getGoodsAmount())
                .couponAmount(orderRedisDTO.getCouponAmount())
                .freight(orderRedisDTO.getFreight())
                .receiveAmount(orderRedisDTO.getReceiveAmount())
                .build();

        return orderBriefVO;
    }
}
